<?php
include 'connexion_bd.php';
session_start();

if ($_SESSION['choix']=='ecrire')
{
	$som_id='SELECT COUNT(*) from nouvelles';
	$res=mysql_query($som_id);
	$tab=mysql_fetch_row($res);
	$nb=$tab[0];
	$nb_id=$nb+1;
	
	$rub='SELECT id_rub from rubriques WHERE nom_rub="'.$_SESSION['rubrique'].'"';
	$res=mysql_query($rub);
	$tab=mysql_fetch_row($res);
	$nb_rub=$tab[0]; 
	//$login='lore';
}
else 
{
	$nb_id=$_SESSION['id_n'];
	$nb_rub=$_SESSION['id_r'];
	$requete='DELETE FROM nouvelles WHERE id_nouv="'.$nb_id.'"';
	mysql_query($requete);
}
	$_SESSION['tit']=$_POST['titre'];
	$_SESSION['txt']=$_POST['nouvelle'];
	
echo $nb_id;
echo $_SESSION['tit'];
echo $nb_rub;
echo $_SESSION['login'];
$date= date("Y-m-d");

$req='INSERT INTO nouvelles VALUES ("'.$nb_id.'","'.$_SESSION['tit'].'","'.$_SESSION['txt'].'","'.$nb_rub.'","'.$_SESSION['login'].'","'.$date.'");'; // a modif 
mysql_query($req);
mysql_close (); 
header ('location:accueil_utilisateur.php')
?>

